require('es6-promise').polyfill();

import axios from 'axios'

function isLogin(isLogin) {
  return {
    type: 'IS_LOGIN',
    isLogin
  }
}

export function apiMsgAction(msg) {
  return {
    type: 'API_MSG',
    msg
  }
}

export function loginSubmitAsync(data) {
  return function(dispatch) {
    return axios.post('/api/users/login', data)
    .then(resp => dispatch(isLogin(true)),
          error => dispatch(isLogin(false))
        )
  }
}
